<?php
/**
 * Authentication Abstraction Class
 * 
 * @package shoehorn
 * @subpackage auth
 * @author Chris "OneSeventeen" Adams
 * @version 0.1
 * 
 */

/**
 * Shoehorn Authentication Class
 * 
 * @package shoehorn
 * @subpackage auth
 *
 */
abstract class Shoehorn_Auth
{
	protected $err;
	
	function __construct(&$err)
	{
		$this->err = $err;
	}
	
	abstract function login($user, $pass);
	abstract function isAuthenticated();
	abstract function getGroups();
	protected abstract function setError($msg, $function, $public=false);
	
	static function getInstance($type, &$err)
	{
		$className = __CLASS__ . '_' . ucwords($type);
		$classFile = SHOEHORN_SCRIPT_FOLDER . '/' .  
		 strtolower($className) . '.class.php';
		if(!class_exists($type)) {
			if(!file_exists($classFile)) {
				echo('could not find ' . $classFile);
				return false;
			}
			if(!require_once($classFile)){
				echo('could not load ' . $classFile);
				return false;
			}
		}
		return new $className($err);
	}
}